﻿/********************************************
Basis of dwsFramework , Writen by CNLei@dws
*********************************************/
Array.prototype.remove = function(dx) {
    if(isNaN(dx) || dx>this.length){return false;}
    this.splice(dx,1);
}
String.prototype.getNumber = function() {return this.replace(/[^\d]/g,""); }
String.prototype.replaceAll = stringReplaceAll;
function stringReplaceAll(AFindText,ARepText){
 var raRegExp = new RegExp(AFindText.replace(/([\(\)\[\]\{\}\^\$\+\-\*\?\.\"\'\|\/\\])/g,"\\$1"),"ig");
 return this.replace(raRegExp,ARepText);
}
var dwsFw = {};
var dwsBrowser = {};
dwsBrowser.agt = navigator.userAgent.toLowerCase();
dwsBrowser.isW3C = document.getElementById ? true:false;
dwsBrowser.isIE = ((dwsBrowser.agt.indexOf("msie") != -1) && (dwsBrowser.agt.indexOf("opera") == -1) && (dwsBrowser.agt.indexOf("omniweb") == -1));
dwsBrowser.isNS6 = dwsBrowser.isW3C && (navigator.appName=="Netscape") ;
dwsBrowser.isOpera = dwsBrowser.agt.indexOf("opera") != -1;
dwsBrowser.isGecko = dwsBrowser.agt.indexOf("gecko") != -1;
dwsBrowser.ieTrueBody  =function (){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
var dwsElement={
  addClassName: function(element, className) {
    if (!(element = $(element))) return;
	dwsElement.delClassName(element, className);
	element.className=element.className+" "+className;
  },
  delClassName: function(element, className) {
    if (!(element = $(element))) return;
	var arrClssOld=element.className.replaceAll("  "," ");
	arrClssOld=arrClssOld.split(" ");
	for (var i=arrClssOld.length-1;i>=0;i--){
	 if (className==arrClssOld[i]){
	 arrClssOld.remove(i);
	 }
	}
	element.className=arrClssOld.join(" ");
  },
	isChild		: function(cNode,pNode){
		while(cNode!=null){
			cNode=cNode.parentNode;
			if(cNode==pNode) return true; 
		}
		return false;
	},
	getChild	: function(oChild,oParent){
		oParent.appendChild(oChild);
	},
	rePos	: function(obj,nLt,nTop){
		var o=$(obj);
		o.style.left	= nLt + "px";
		o.style.top		= nTop + "px";
	},
	getXYWH	: function(o){
		var nLt=0;
		var nTp=0;
		var offsetParent = o;
		while (offsetParent!=null && offsetParent!=document.body) {
			nLt+=offsetParent.offsetLeft;
			nTp+=offsetParent.offsetTop;
			if(dwsBrowser.isIE){
				parseInt(offsetParent.currentStyle.borderLeftWidth)>0?nLt+=parseInt(offsetParent.currentStyle.borderLeftWidth):"";
				parseInt(offsetParent.currentStyle.borderTopWidth)>0?nTp+=parseInt(offsetParent.currentStyle.borderTopWidth):"";
			}
			offsetParent=offsetParent.offsetParent;
		}
		return {"X":nLt, "Y":nTp, "W":o.offsetWidth, "H":o.offsetHeight}
	}
}
var dwsPosition={
	rePos	: function(obj,nLt,nTop){
		var o=$(obj);
		o.style.left	= nLt + "px";
		o.style.top		= nTop + "px";
	}
}
function $(element) {
	return document.getElementById(element)?document.getElementById(element):element;
}
document.getElementsByClassName = function(className,oBox) {
	 this.d= oBox || document;
	 var children = this.d.getElementsByTagName('*') || document.all;
	 var elements = new Array();
	 for (var i = 0; i < children.length; i++) {
		 var child = children[i];
		 var classNames = child.className.split(' ');
		 for (var j = 0; j < classNames.length; j++) {
			 if (classNames[j] == className) {
				 elements.push(child);
				 break;
			 }
		 }
	 }
	 return elements;
}

$Cls = document.getElementsByClassName ;
var dwsTAB = {
	idSuffix		: "_Tabs",
	tabTagName		: "li",
	activeClassName	: "active",
	waitInterval	: null,
	delayTime		: 30,
	tempTAB			: null
}
dwsTAB.init = function(){
	for(var i=0;i<arguments.length;i++) {
			var oTabBox=document.getElementById(arguments[i]+dwsTAB.idSuffix);
			var arrTabs=oTabBox.getElementsByTagName(dwsTAB.tabTagName);	
			var oCurrTAB=null;
			for(var j=0;j<arrTabs.length;j++) {
				oCurrTAB=arrTabs[j];
				if(oCurrTAB.parentNode!=oTabBox) continue;
				var oTabLink=oCurrTAB.getElementsByTagName("a")[0];
				var sDataStaut=oTabLink.getAttribute("rel");
				oCurrTAB.setActive=function(bactive){
					var oDataId = this.getElementsByTagName("a")[0].getAttribute("urn");
					if(bactive){
						this.status="active";
						dwsElement.addClassName(this,dwsTAB.activeClassName);
						dwsElement.delClassName($(oDataId),"hidden");
					}else{
						this.status="normal";
						dwsElement.delClassName(this,dwsTAB.activeClassName);
						dwsElement.addClassName($(oDataId),"hidden");
					}
				}
				oCurrTAB.getTabData=function(){
					this.setActive(true);
					this.parentNode.activetab.setActive(false);
					this.parentNode.activetab=this;					
					var oTabLink=this.getElementsByTagName("a")[0];
				}
				oCurrTAB.onmouseover=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var fm=myEvent.fromElement;
					if(dwsElement.isChild(fm,this) || fm==this) return;
					if(this.status=="active") return;
					dwsTAB.tempTAB=this;
					clearTimeout(dwsTAB.waitInterval);
					dwsTAB.waitInterval=window.setTimeout("dwsTAB.tempTAB.getTabData();",dwsTAB.delayTime);
				}
				oCurrTAB.onmouseout=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var em=myEvent.toElement;
					if(dwsElement.isChild(em,this) || em==this) return;
					if(this.status=="active") return;
					clearTimeout(dwsTAB.waitInterval);
				}
				if(sDataStaut.indexOf("#default")!=-1){
					oCurrTAB.setActive(true);
					oTabBox.activetab=oCurrTAB;
				} else {
					oCurrTAB.setActive(false);
				}

			}
		if(oTabBox.activetab==null) oTabBox.activetab=arrTabs[0];
	}
}

dwsTAB.init2 = function(){
	for(var i=0;i<arguments.length;i++) {
			var oTabBox=document.getElementById(arguments[i]+dwsTAB.idSuffix);
			var arrTabs=oTabBox.getElementsByTagName(dwsTAB.tabTagName);	
			var oCurrTAB=null;
			for(var j=0;j<arrTabs.length;j++) {
				oCurrTAB=arrTabs[j];
				if(oCurrTAB.parentNode!=oTabBox) continue;
				var oTabLink=oCurrTAB.getElementsByTagName("a")[0];
				var sDataStaut=oTabLink.getAttribute("rel");
				oCurrTAB.setActive=function(bactive){
					var oDataId = this.getElementsByTagName("a")[0].getAttribute("urn");
					if(bactive){
						this.status="active";
						dwsElement.addClassName(this,dwsTAB.activeClassName);
						dwsElement.delClassName($(oDataId),"hidden");
					}else{
						this.status="normal";
						dwsElement.delClassName(this,dwsTAB.activeClassName);
						dwsElement.addClassName($(oDataId),"hidden");
					}
				}
				oCurrTAB.getTabData=function(){
					this.setActive(true);
					this.parentNode.activetab.setActive(false);
					this.parentNode.activetab=this;					
					var oTabLink=this.getElementsByTagName("a")[0];
				}
				oCurrTAB.onclick=function(aEvent){
					var myEvent = window.event ? window.event : aEvent;
					var fm=myEvent.fromElement;
					if(dwsElement.isChild(fm,this) || fm==this) return;
					if(this.status=="active") return;
					dwsTAB.tempTAB=this;
					dwsTAB.tempTAB.getTabData();
					//clearTimeout(dwsTAB.waitInterval);
					//dwsTAB.waitInterval=window.setTimeout("dwsTAB.tempTAB.getTabData();",dwsTAB.delayTime);
				}
				if(sDataStaut.indexOf("#default")!=-1){
					oCurrTAB.setActive(true);
					oTabBox.activetab=oCurrTAB;
				} else {
					oCurrTAB.setActive(false);
				}

			}
		if(oTabBox.activetab==null) oTabBox.activetab=arrTabs[0];
	}
}

dwsFw.setHome = function(o,s){
	if (dwsBrowser.isIE) {
		o.style.behavior='url(#default#homepage)';
		o.setHomePage(s);
		return(false);
	}
}
dwsFw.addFavUrl = function(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( dwsBrowser.isIE ) {
		window.external.AddFavorite( url, title);
	} else if(dwsBrowser.isOpera && window.print ) {
		  var elem = document.createElement('a');
		  elem.setAttribute('href',url);
		  elem.setAttribute('title',title);
		  elem.setAttribute('rel','sidebar');
		  elem.click();
	}
}
var oldBoxNo=0;
function nextFace(sParentId,sSubBoxTag,n){
var arrFaceBox=$(sParentId).getElementsByTagName(sSubBoxTag);
var nNewBoxNo=oldBoxNo+n;
nNewBoxNo<0?nNewBoxNo=(arrFaceBox.length-1):"";
nNewBoxNo>=arrFaceBox.length?nNewBoxNo=0:"";
for (var i=0;i<arrFaceBox.length;i++ ) {
 arrFaceBox[i].style.display=i==nNewBoxNo?"":"none";/**/
}
oldBoxNo=nNewBoxNo;
}
var dwsPopMsg = {};
dwsPopMsg.show = function(o,sId,nOffX,nOffY){
this.offX = nOffX || 0;
this.offY = nOffY || 0;
var oBox = $(sId);
var nPos = dwsElement.getXYWH(o);
var nLt,nTop;
nLt = nPos.X + (nPos.W/2) + this.offX;
nTop = nPos.Y + this.offY;
dwsElement.rePos(oBox,nLt,nTop);
dwsElement.delClassName(oBox,"hidden");
//alert(nPos.X);
}
dwsPopMsg.close = function(sId){
var oBox = $(sId);
dwsElement.addClassName(oBox,"hidden");
}
function chgInp(o){
	o.value=o.value==o.defaultValue?"":o.value;
	o.onblur= function(){
		this.value=this.value==""?this.defaultValue:this.value;
	}
}

try{document.execCommand("BackgroundImageCache", false, true);
}catch(e){} 